package cn.swust.designpatternlearningplatform.dao.sql;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;
@Slf4j
public class StudentDaoSql {

 /**
  * @param number:
   * @return String
  * @author wang
  * @description 获取学生的基本信息
  * @date 2023/4/16 21:04
  */
    public String getStudentByNumber(@Param("number") String number){
        return new SQL(){
            {
                SELECT("*");
                FROM("student");
                WHERE("student_number=#{number}");
            }
        }.toString();
    }
    /**
     * @param number:
      * @return String
     * @author wang
     * @description 获取学生头像路径
     * @date 2023/4/16 21:08
     */
   public String getHeadByStudentNumber(String number){
        return new SQL(){
            {
                SELECT("head_portrait");
                FROM("student");
                WHERE("student_number=#{number}");
            }
        }.toString();
   }
   /**
    * @param studentNumber:
   	 * @param valueOf:
     * @return String
    * @author wang
    * @description 头像已经存在进行一个直接修改
    * @date 2023/4/16 21:12
    */
   public String updateHead(String studentNumber, String valueOf){
       return new SQL(){
           {
               UPDATE("student");
               SET("head_portrait=#{valueOf}");
               WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
   	 * @param valueOf:
     * @return String
    * @author wang
    * @description 上传头像
    * @date 2023/4/16 21:20
    */
   public String UploadHead(String studentNumber, String valueOf){
       return new SQL(){
           {
               UPDATE("student");
               SET("head_portrait=#{valueOf}");
               WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
     * @return String
    * @author wang
    * @description 查找头像路径给前端
    * @date 2023/4/16 21:43
    */
   public String getHeadPortrait(String studentNumber){
       return new SQL(){
           {
               SELECT("head_portrait");
               FROM("student");
               WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
     * @return String
    * @author wang
    * description 获取热力图数据
    * date 2023/4/17 19:35
    */
   public String QueryNumber(String studentNumber){
       return new SQL(){
           {
               SELECT("topic_id","problem_time");
               FROM("daily_exercise");
               WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
     * @return String
    * @author wang
    * description 获取收藏，错题，屏蔽题目的数量
    * date 2023/4/17 19:35
    */
   public String getAllTypeTopicNumber(String studentNumber){
       return new SQL(){
           {
               SELECT("update_type");
               FROM("topic_update");
               WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
     * @return String
    * @author wang
    * description 获取自己的做题情况
    * date 2023/4/17 19:38
    */
   public String getSelfNumber(String studentNumber){
       return new SQL(){
           {
            SELECT("is_right");
            FROM("daily_exercise");
            WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
     * @return String
    * @author wang
    * description 获取其他人的做题数量
    * date 2023/4/17 19:42
    */
   public String getOtherSelfNumber(String studentNumber){
       return new SQL(){
           {
               SELECT("is_right");
               FROM("daily_exercise");
               WHERE("student_number<>#{studentNumber}");
           }
       }.toString();
   }
   /**
    * @param studentNumber:
     * @return String
    * @author wang
    * description 获取学生关联的老师以及班级和学期
    * date 2023/5/14 16:04
    */
   public String getStudentTestPaperData(String studentNumber){
       return new SQL(){
           {
               SELECT("teacher_account","class_number","semester");
               FROM("student");
               WHERE("student_number=#{studentNumber}");
           }
       }.toString();
   }
    /**
     * @param studentNumber:
     * @return String
     * @author wang
     * description 通过学号查找学生的姓名，用于做试卷的题目
     * date 2023/6/1 16:21
     */
    public String getStudentName(String studentNumber){
        return new SQL(){
            {
                SELECT("student_name");
                FROM("student");
                WHERE("student_number=#{studentNumber}");
            }
        }.toString();
    }
}
